package org.wak.gui.custom
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.DropShadowFilter;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;

	/**
	 * Class to display info of the Scene's item in the mouse pointer. 
	 * 
	 */
	public class MouseInfoBox extends Sprite
	{
		private var mTextBox:TextField = null ;
		
		private var mBackground:DisplayObject = null ;
		
		// shadow filter
		private var mOutline:DropShadowFilter = null ;

		/**
		 * Constructor. 
		 * 
		 */				
		public function MouseInfoBox()
		{
			super();
			mTextBox = new TextField();
			mTextBox.selectable = false;
			mTextBox.y = 12;
			
			mTextBox.mouseEnabled = false;
			this.buttonMode = false;

			//mTextBox.background = true ;
			this.addChild(mTextBox);
			mTextBox.autoSize = TextFieldAutoSize.LEFT ;
			
			mOutline = new DropShadowFilter(1, 31, 0x000000, 1, 6, 6, 4, BitmapFilterQuality.LOW, false, false, false);
		}
		
		/**
		 * Text to display in the MouseInfoBox. 
		 * @param value string with the item's name.
		 * 
		 */		
		public function set text(value:String):void
		{
			mTextBox.text = value ;
			if(mTextBox.text == "" )
				this.visible = false ;
			else
				this.visible = true ;
		}
		
		/**
		 * 
		 * @private 
		 * 
		 */		
		public function get text():String
		{
			return mTextBox.text ;
		}
		
		/**
		 * TextFormat to change the font style of the MouseInfoBox. 
		 * @param value a TextFormat.
		 * 
		 */		
		public function set textFormat(value:TextFormat):void
		{
			mTextBox.defaultTextFormat = value ;
		}
		
		/**
		 * Set a DisplayObject as background. 
		 * @param value DisplayObject.
		 * 
		 */		
		public function set background(value:DisplayObject):void
		{
			this.addChild(value);
			mBackground = value ;
			this.setChildIndex(mBackground,0);
			
		}
		
		/**
		 * Enable and set the flat border for the MouseInfoBox.
		 * Visible only if not background image was previously set. 
		 * @param value border color.
		 * 
		 */		
		public function set border(value:uint):void
		{
			mTextBox.border = true ;
			mTextBox.borderColor = value ;
		}
		
		/**
		 * Enable and set a color for the flat color background.
		 * Visible only if not background image was previously set. 
		 * @param value background color.
		 * 
		 */		
		public function set flatBgColor( value:uint ):void
		{
			mTextBox.background = true ;
			mTextBox.backgroundColor = value ;
		}
		
		/**
		 * Enable or disable the text outline . 
		 * @param value 
		 * 
		 */		
		public function set outline( value:Boolean ):void
		{
			if(value)
			{
				mTextBox.filters = [mOutline] ;
			}
			else
			{
				mTextBox.filters = null ;
			}
		}
		
		/**
		 * Enable or disable the use of embed fonts. 
		 * @param value
		 * 
		 */		
		public function set embedFonts( value:Boolean ):void
		{
			mTextBox.embedFonts = value ;
		} 
		
		public override function get width():Number
		{
			return mTextBox.width ;
		}
		
		public function set txtFieldWidth(value:Number):void
		{
			mTextBox.width = value ;
			mTextBox.wordWrap = true ;
			//mTextBox.autoSize = TextFieldAutoSize.NONE ;
			
		}
		
	}
}